/**
 * Copyright (C) 2018-2020
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package co.yixiang.modules.common.rest;

import co.yixiang.api.ApiResult;
import co.yixiang.modules.commom.domain.YxAppdict;
import co.yixiang.modules.commom.domain.YxProblem;
import co.yixiang.modules.commom.service.YxAppdictService;
import co.yixiang.modules.commom.service.YxProblemService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(value = "常见问题", tags = "公共:常见问题", description = "常见问题")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class YxProblemController {

    private final YxProblemService yxProblemService;

    /**
     * 查看问题列表
     */
    @GetMapping("/findProblemList")
    @ApiOperation(value = "查看问题列表",notes = "查看问题列表")
    public ApiResult<Page<YxProblem>> findProblemList(@RequestParam(value = "page",defaultValue = "1") int page,
                                                      @RequestParam(value = "limit",defaultValue = "10") int limit){
        return ApiResult.ok(yxProblemService.findProblemList(page,limit));
    }

    /**
     * 根据id查询问题详情
     */
    @GetMapping("/findProblemDetail/{id}")
    @ApiOperation(value = "根据id查询问题详情",notes = "根据id查询问题详情")
    public ApiResult<YxProblem> findProblemDetail(@PathVariable Long id){
        return ApiResult.ok(yxProblemService.getById(id));
    }

}

